﻿using System.Web.Mvc;
using LogikBug.ModularMvc;
using LogikBug.ModularMvc.Navigation;
using LogikBug.ModularMvc.Registration;

namespace Test.Site
{
	public class DefaultModule : VisualModule
	{
		#region Constructors

		public DefaultModule()
		{
			Name = "Home";
			OrderPrecedence = 99999.9m;
			MenuDisplayOrder = 1;
		}

		#endregion

		protected override void Initialize(IRegistrationContext context)
		{
			context.Routes.MapRoute(
				this,
				"DefaultRoute",
				string.Empty,
				new { controller = "Home", action = "Index" }
			);
			context.Routes.MapRoute(
				this,
				"DefaultHomeRoute",
				"{controller}/{action}/{id}",
				new { controller = "Home", action = "Index", id = UrlParameter.Optional },
				new[] { "Test.Site.Controllers" }
			);
		}

		public override MenuItemCollection GetMenu(ViewContext viewContext, MenuType menuType)
		{
			if (menuType == MenuType.Main)
			{
				return new MenuItemCollection
				{
					new MenuItem("/", "Home")
				};
			}

			return null;
		}
	}
}